@isTest
private class test_CXGUpdateAccount
{
 /* 
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */ 
      
   static testMethod void myUnitTestTrigger() 
    {
     
     Account acct = New Account();
     acct.Name='TestAccount';
     acct.CSS_CustomerID__c='9100102335';
     Insert acct;//inserting  a Test account
     
     Campaign parentcamp = New Campaign();
     parentcamp.Name='Parent Campaign';
     parentcamp.StartDate=Date.Today();
     parentcamp.EndDate=Date.Today()+14;
     Insert parentcamp;//Inserting  a Parent campaign
     
     Campaign camp= New Campaign();
     camp.Name='Campaign Wave1';
     camp.ParentId=parentcamp.Id;
     camp.IsActive=true;
     camp.StartDate=Date.Today();
     Camp.EndDate=Date.Today()+7;
     Insert camp;
     
     CXG_Campaign_Accounts__c campaignmember= New CXG_Campaign_Accounts__c();
     campaignmember.Campaign__c=camp.Id;
     campaignmember.Customer__c=acct.Id;
     campaignmember.IscampaignActive__c=camp.IsActive;
     Insert campaignmember;
     campaignmember.Control_Group_Member__c=true;
     campaignmember.Churnstatus__c=acct.Churn_Status__c;
     update  campaignmember;
     ID CxGIOGAccountRecordtypID = RecordTypeHelper.GetRecordTypeIdByDevName('Account', 'CSS_Customer');
     Customer_Retention__c cr= New Customer_Retention__c();
     cr.Related_Account__c=acct.Id;
     cr.Status__c='C';
     cr.YYYY_MM__c='2011/04';
     Insert cr;     
     acct.Control_Group__c=true;
     acct.Has_Account_Churned__c=true;
     acct.RecordTypeId=CxGIOGAccountRecordtypID;
     acct.Churn_Status__c='C';
     update acct;
          
          
    }
    static testMethod void myUnitTestACCTClass() 
    {
      Account acct = New Account();
      acct.Name='TestAccount';
      acct.CSS_CustomerID__c='9100102331';
      Insert acct;//inserting  a Test account
      List<Customer_Retention__c> lstcr= New List<Customer_Retention__c>();
      Customer_Retention__c cr= New Customer_Retention__c();
      cr.Related_Account__c=acct.Id;
      cr.Status__c='C';
      cr.YYYY_MM__c='2011/04';
      lstcr.add(cr);
      Insert lstcr;   
      List<Account> actlist=  New List<Account>();
      CXGAccountUpdateOperation.CustomerRetentionAccountUpdate(lstcr);
      acct= New Account(Id=cr.Related_Account__c);
      acct.Churn_Status__c=cr.Status__c;  
      acct.Month_Year__c=cr.Date__c;
      actlist.add(acct);
      Update actlist;
    }
    static testMethod void myUnitTestCONTClass()
    {
      Account acct = New Account();
      acct.Name='TestAccount';
      acct.CSS_CustomerID__c='9100102333';
      Insert acct;//
      ID CxGcontactRecordtypID = RecordTypeHelper.GetRecordTypeIdByDevName('Contact', 'Standard_Contact_Record_Type'); 
      ID CxGIOGcontactRecordtypID = RecordTypeHelper.GetRecordTypeIdByDevName('Contact', 'CSS_Contact'); 
      List<Account> actlist=  New List<Account>();
      List<Account> actlistIOG=  New List<Account>();
      List<Contact> cntlst= New List<Contact>();
      Contact cnt= New Contact();
      cnt.LastName='test';
      cnt.accountId= acct.Id;
      cnt.MobilePhone='9663388400';
      cnt.Fax='123456';
      cnt.Email='test@accenture.com';
      cnt.Phone='9663388400';
      cnt.IsPrimary_Contact__c=true;
      cnt.source_type__c='CSS';
      cnt.RecordTypeId=CxGIOGcontactRecordtypID;
      cntlst.add(cnt);
      Contact cntiog= New Contact();
      cntiog.LastName='test1';
      cntiog.accountId= acct.Id;
      cntiog.MobilePhone='9663388400';
      cntiog.Fax='123456';
      cntiog.Email='tes1t@accenture.com';
      cntiog.Phone='9663388400';
      //cntiog.IsPrimary_Contact__c=true;
      cntiog.source_type__c='CXG';
      cntiog.RecordTypeId=CxGIOGcontactRecordtypID;
      //cntlst.add(cntiog);
      Insert cntiog;
      cntiog.IsPrimary_Contact__c=true;
      update cntiog;
      insert cntlst;
      
      CXGContactOperation.ContacttoAccountUpdate(cntlst);
      acct= New Account(Id=cnt.accountId);
      acct.CxG_Contact__c=cnt.Id;
      acct.CxG_Contact_TimeZone__c=cnt.Time_zone__c; 
      acct.CxG_Mobile_number__c=cnt.MobilePhone; 
      acct.CxG_Contact_Phone__c=cnt.Phone; 
      acct.CXG_Contact_Email__c=cnt.Email; 
      acct.CXG_Contact_Fax__c=cnt.Fax;
      actlist.add(acct); 
      update actlist;
      Account actiog=New Account(Id=cntiog.accountId);
      actiog.CXG_Contact_Name__c=cntiog.Id;
      actlistIOG.add(actiog);
      update actlistIOG;
           
     }
     static testMethod void myUnitTestREFRESH() 
     {
     CwsRestClient cws = new CwsRestClient();
     //CssNote css= new CssNote();
     Account acct = New Account();
     acct.Name='TestAccount';
     acct.CSS_CustomerID__c='9100086443';
     Insert acct;//inserting  a Test account
    
     List<notes__c> notelist= New List<notes__c>();
     notes__c n= New notes__c();
     n.Notes__c='Test';
     n.Account__c=acct.Id;
     n.Note_Type__c='BATCH'; 
     n.Date__c=DateTime.Now();
     n.Note__c='Finance';
     notelist.add(n);
     Insert notelist;
     
     //CwsRestClient.temp1 = true;
     CwsRestClient.CSSNotesCall('9100086443');
     //List<CwsRestClient.CssNote> notes=CwsRestClient.GetCssNotes('9100086443', 'A', 40);
     //System.assert(notes != null);

     }
     static testMethod void myUnitTestCTRGRP() 
     {
     Account acct = New Account();
     acct.Name='TestAccount';
     acct.CSS_CustomerID__c='9100102314';
     Insert acct;//inserting  a Test account
     
     Campaign parentcamp = New Campaign();
     parentcamp.Name='Parent Campaign';
     parentcamp.StartDate=Date.Today();
     parentcamp.EndDate=Date.Today()+14;
     Insert parentcamp;//Inserting  a Parent campaign
     List<Campaign> lstcamp = New List<Campaign>();
     Campaign camp= New Campaign();
     camp.Name='Campaign Wave1';
     camp.ParentId=parentcamp.Id;
     camp.IsActive=true;
     camp.Number_of_Control_Group_Members__c=1;
     camp.StartDate=Date.Today();
     Camp.EndDate=Date.Today()+7;
     lstcamp.add(camp);
     insert lstcamp;
     ID usr=UserInfo.getUserId();
     List<CXG_Campaign_Accounts__c> lstcm= new List<CXG_Campaign_Accounts__c>();
     CXG_Campaign_Accounts__c campaignmember= New CXG_Campaign_Accounts__c();
     campaignmember.Campaign__c=camp.Id;
     campaignmember.Customer__c=acct.Id;
     campaignmember.OwnerId=usr;
     campaignmember.IscampaignActive__c=camp.IsActive;
     campaignmember.Control_Group_Member__c=true;
     lstcm.add(campaignmember);
     Insert lstcm;
          //campaignmember.Churnstatus__c=acct.Churn_Status__c;
     //update  lstcm;
     CxG_CampaignMemberControlGroup cgrp= New CxG_CampaignMemberControlGroup();
     cgrp.AssignControlGroupMember(lstcamp);
     cgrp.masterFetchedCampaignMember(lstcm);
     List<CXG_Campaign_Accounts__c> lstcmremv= new List<CXG_Campaign_Accounts__c>();
     //CXG_Campaign_Accounts__c campaignmember1= New CXG_Campaign_Accounts__c();
     QueueSobject Qid = [Select QueueId from QueueSobject where Queue.Name ='Agent Queue' LIMIT 1];
     campaignmember.Campaign__c=camp.Id;
     campaignmember.Customer__c=acct.Id;
     campaignmember.Control_Group_Member__c=false;
     campaignmember.OwnerId=Qid.Queueid;
     Update lstcm;
     cgrp.RemoveControlGroupMember(lstcm); 
     }
     static testMethod void myUnitTestDNC() 
     {
     Account acct = New Account();
     acct.Name='TestAccount';
     acct.CSS_CustomerID__c='9100108319';
     Insert acct;//inserting  a Test account
     acct.CXG_Do_Not_Call__c=True;
     Update acct;
     Campaign parentcamp = New Campaign();
     parentcamp.Name='Parent Campaign';
     parentcamp.StartDate=Date.Today();
     parentcamp.EndDate=Date.Today()+14;
     Insert parentcamp;//Inserting  a Parent campaign
     ID CxGCampaignMemberRecordTypeId= RecordTypeHelper.GetRecordTypeIdByDevName('CXG_Campaign_Accounts__c', 'Campaign_Member');
     Campaign camp= New Campaign();
     camp.Name='Campaign Wave1';
     camp.ParentId=parentcamp.Id;
     camp.IsActive=true;
     camp.StartDate=Date.Today();
     Camp.EndDate=Date.Today()+7;
     Insert camp;
     CXG_Campaign_Accounts__c campaignmember= New CXG_Campaign_Accounts__c();
     campaignmember.Campaign__c=camp.Id;
     campaignmember.Customer__c=acct.Id;
     campaignmember.Status__c='New';
     campaignmember.RecordTypeId=CxGCampaignMemberRecordTypeId;
     campaignmember.IscampaignActive__c=camp.IsActive;
     campaignmember.CXG_Do_Not_Call__c=True;
     campaignmember.Status__c='Closed';
     Insert campaignmember;
     Account acct1 = New Account();
     acct1.Name='Test';
     acct1.CSS_CustomerID__c='9100108310';
     Insert acct1;
     acct1.Line_Disconnected_Fax_Line__c=True;
     Update acct1;
     CXG_Campaign_Accounts__c campaignmember1= New CXG_Campaign_Accounts__c();
     campaignmember1.Campaign__c=camp.Id;
     campaignmember1.Customer__c=acct1.Id;
     campaignmember1.RecordTypeId=CxGCampaignMemberRecordTypeId;
     campaignmember1.IscampaignActive__c=camp.IsActive;
     campaignmember1.Disposition__c='Line Disconnected / Fax Line';
     campaignmember1.Status__c='Closed';
     Insert campaignmember1;
     }
 }